<template>
  <div style="position: relative">
    <div class="content">
      <div class="info">
        <div class="title">{{ basicInfo.title }}</div>
        <div class="list">
          <div class="item">
            <div class="tit">创建时间</div>
            <div class="desc">{{ info.gmtCreated }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            ></div>
          </div>
          <div class="item">
            <div class="tit">商户订单号</div>
            <div class="desc">{{ info.redNo }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            >
              <i
                class="el-icon-document-copy"
                @click="copyAppId(info.redNo)"
              ></i>
            </div>
          </div>
          <div class="item">
            <div class="tit">商户号</div>
            <div class="desc">{{ info.memberId }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            ></div>
          </div>
          <div class="item">
            <div class="tit">APP ID</div>
            <div class="desc">{{ info.appId }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            ></div>
          </div>
          <div class="item">
            <div class="tit">红包类型</div>
            <div class="desc">普通红包</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            ></div>
          </div>
          <div class="item">
            <div class="tit">红包个数</div>
            <div class="desc">{{ info.num }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            ></div>
          </div>
          <div class="item">
            <div class="tit">红包金额</div>
            <div class="desc">{{ info.fmtAmount }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            ></div>
          </div>
          <div class="item">
            <div class="tit">活动名称</div>
            <div class="desc">{{ info.subject }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            ></div>
          </div>
          <div class="item">
            <div class="tit">活动描述</div>
            <div class="desc">{{ info.description }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            ></div>
          </div>
          <div class="item">
            <div class="tit">红包状态</div>
            <div class="desc">{{ setPayStatus(info.status) }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            ></div>
          </div>
          <!-- <div
            class="item"
            v-for="(item, index) of basicInfo.infoList"
            :key="index"
          >
            <div class="tit">{{ item.title }}</div>
            <div class="desc">{{ item.data }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            >
              <i
                class="el-icon-document-copy"
                v-if="item.copy"
                @click="copyAppId(item.data)"
              ></i>
            </div>
          </div> -->
        </div>
      </div>
      <div class="info">
        <div class="title">{{ payInfo.title }}</div>
        <div class="list">
          <div class="item">
            <div class="tit">用户</div>
            <div class="desc">{{ info.receiveUser }}</div>
          </div>
          <!-- <div
            class="item"
            v-for="(item, index) of payInfo.infoList"
            :key="index"
          >
            <div class="tit">{{ item.title }}</div>
            <div class="desc">{{ item.data }}</div>
          </div> -->
        </div>
      </div>
      <div class="info">
        <div class="title">{{ merchantInfo.title }}</div>
        <div class="list">
          <div class="item">
            <div class="tit">是否退款</div>
            <div class="desc">
              {{
                info.status == "rfunding" || info.status == "refund"
                  ? "是"
                  : "否"
              }}
            </div>
          </div>
          <div
            class="item"
            v-if="info.status == 'rfunding' || info.status == 'refund'"
          >
            <div class="tit">退款时间</div>
            <div class="desc">
              {{ info.refundTime }}
            </div>
          </div>
          <div
            class="item"
            v-if="info.status == 'rfunding' || info.status == 'refund'"
          >
            <div class="tit">退款金额</div>
            <div class="desc">
              {{ info.fmtRefundAmount }}
            </div>
          </div>
          <!-- <div
            class="item"
            v-for="(item, index) of merchantInfo.infoList"
            :key="index"
          >
            <div class="tit">{{ item.title }}</div>
            <div class="desc">{{ item.data }}</div>
          </div> -->
        </div>
      </div>
    </div>
    <div class="back" @click="backFn">
      <i class="el-icon-close"></i>
    </div>
    <div class="left">
      <el-breadcrumb separator=">" style="margin-bottom: 20px">
        <el-breadcrumb-item v-for="item of breadList" :key="item">{{
          item
        }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
  </div>
</template>

<script>
export default {
  name: "wechatRedPacketDetail",
  components: {},
  data() {
    return {
      breadList: [],
      info: {},
      basicInfo: {
        title: "基本信息",
        infoList: [
          {
            title: "创建时间",
            data: "2023-01-23 14:00",
          },
          {
            title: "商户订单号",
            data: "87930235949282",
            copy: "true",
          },
          {
            title: "云尘付流水号",
            data: "YC739008937420535",
            copy: "true",
          },
          {
            title: "商户号",
            data: "100000098",
          },
          {
            title: "APP ID",
            data: "wxe036346456465",
          },
          {
            title: "红包类型",
            data: "普通红包",
          },
          {
            title: "红包个数",
            data: "20",
          },
          {
            title: "红包金额",
            data: "￥415.55",
          },
          {
            title: "活动名称",
            data: "元宵祝福红包",
          },
          {
            title: "活动描述",
            data: "拼手速！抢就是赚到！",
          },
          {
            title: "红包状态",
            data: "已退款",
          },
        ],
      },
      payInfo: {
        title: "领取信息",
        infoList: [
          {
            title: "用户",
            data: "oxTWIuGaIt6gTKsQRLau2M0yL16E\nWou903jklfXjopejiejf\n3Gojoijjdsgwggo",
          },
        ],
      },
      merchantInfo: {
        title: "退款信息",
        infoList: [
          {
            title: "是否退款",
            data: "是",
          },
          {
            title: "退款时间",
            data: "2023-03-12 14:00",
          },
          {
            title: "退款金额",
            data: "￥20.40",
          },
        ],
      },
    };
  },
  created() {
    this.breadList = this.$route.meta.title;
    //console.log(this.$route.query.id);
    let id = this.$route.query.id;
    if (id) {
      this.$http.get("/api/merchant/redPacketInfo/get?id=" + id).then((res) => {
        if (res.code === "0000") {
          //console.log(res.data);
          this.info = res.data;
        }
      });
    }
  },
  methods: {
    setPayStatus(val) {
      let str = "";
      switch (val) {
        case "sending":
          str = "发放中";
          break;
        case "send":
          str = "发放待领取";
          break;
        case "failed":
          str = "发放失败";
          break;
        case "received":
          str = "已领取";
          break;
        case "rfunding":
          str = "退款中";
          break;
        case "refund":
          str = "已退款";
          break;
      }
      return str;
    },
    backFn() {
      this.$backTo(`/marketingTool/weChatRedPacket`);
    },
    copyAppId(value) {
      const input = document.createElement("input"); // 创建input对象
      input.value = value; // 设置复制内容
      document.body.appendChild(input); // 添加临时实例
      input.select(); // 选择实例内容
      document.execCommand("Copy"); // 执行复制
      document.body.removeChild(input); // 删除临时实例
      this.$message.success("复制成功！");
    },
  },
};
</script>

<style scoped lang="scss">
.content {
  min-height: 780px;
  padding: 160px 100px;
  display: flex;
  justify-content: start;
  flex-wrap: wrap;
  .info {
    width: 33.3%;
    min-width: 500px;
    margin-bottom: 40px;
    padding: 0 2%;
    .title {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #1d1c1c;
      padding-bottom: 15px;
      border-bottom: 1px solid #03bfc6;
    }
    .list {
      margin-top: 35px;
      .item {
        display: flex;
        .tit {
          min-width: 100px;
          margin-right: 32px;
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #869daa;
          line-height: 40px;
          text-align: right;
        }
        .desc {
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #1d1c1c;
          line-height: 40px;
          overflow: hidden;
          word-wrap: break-word;
        }
      }
    }
  }
}
.back {
  position: absolute;
  right: 55px;
  top: 20px;
  font-size: 20px;
  cursor: pointer;
}
.left {
  position: absolute;
  left: 55px;
  top: 31px;
  height: 20px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #869daa;
  line-height: 20px;
}
// :deep(.el-table__expand-icon) {
//   // position: absolute;
//   // left:140px;
//   float: left;
// }
@media screen and (max-width: 1770px) {
  .content {
    .info {
      box-sizing: content-box !important;
      width: 33.3%;
      min-width: 520px;
      margin-bottom: 40px;
      padding: 0 5.5%;
    }
  }
}

@media screen and (max-width: 1550px) {
  .content {
    .info {
      box-sizing: content-box !important;
      width: 33.3%;
      min-width: 488px;
      margin-bottom: 40px;
      padding: 0 2%;
    }
  }
}
</style>
